package lormi.meipin.controller.api;

import lormi.meipin.annotation.NotValidUser;
import lormi.meipin.common.Result;
import lormi.meipin.controller.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 七牛
 * */
@RestController
@RequestMapping(value="v2/qiniu/",method=RequestMethod.POST,produces = "application/json; charset=utf-8")
public class QiNiuController extends BaseController{

	/**
	 * 获取七牛uptoken
	 * */
	@NotValidUser
	@RequestMapping(value="uptoken")
	public String uptoken() throws Exception{
		
		return Result.success(qiNiuService.getUpLoadToken());
	}
	
	/**
	 * 图片流上传
	 * */
	@NotValidUser
	@RequestMapping(value="up")
	@Valid
	public String up(@NotNull(message="100033") @RequestParam(value="base64img",required=false) String base64img) throws Exception{
		return Result.success(qiNiuService.upload(base64img));
	}
	
}
